package com.dlb.andorid.presenter;

import com.dlb.andorid.XAPI;
import com.dlb.andorid.XContract;
import com.dlb.andorid.XPresenter;
import com.dlb.andorid.XServerMsg;
import com.dlb.andorid.bean.UserInfo;

import java.util.HashMap;

public class PointPresenter extends XPresenter {

	XContract.IPointView iView;

	public PointPresenter(XContract.IPointView iView) {
		super(iView);
		this.iView = iView;
	}

	public void exchange(long exchange_num) {
		mModel.exchangePoint(exchange_num);
	}

	public void getUserInfo() {
		mModel.getUserInfo();
	}


	@Override
	public void onDataSuccess(int vocational_id, HashMap<String, Object> exData, Object data) {
		super.onDataSuccess(vocational_id, exData, data);

		switch (vocational_id) {
			case XAPI.GET_POINT_EXCHANGE_VOCATIONAL_ID:
				iView.exchangeSuccess((XServerMsg) data);
				break;
			case XAPI.GET_USER_INFO_VOCATIONAL_ID:
				iView.getUserInfoSuccess(((XServerMsg<UserInfo>)data).getData());
				break;
		}

	}
}
